package com.tourism.controller;

import com.tourism.common.Result;
import com.tourism.entity.ActivityBooking;
import com.tourism.service.ActivityBookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/admin/activityBooking")
@CrossOrigin
public class ActivityBookingController {

    @Autowired
    private ActivityBookingService activityBookingService;

    @GetMapping("/list")
    public Result getBookingList(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String userName,
            @RequestParam(required = false) String activityName) {
        return activityBookingService.getBookingList(page, pageSize, userName, activityName);
    }

    @GetMapping("/{id}")
    public Result getBookingById(@PathVariable Integer id) {
        return activityBookingService.getBookingById(id);
    }

    @PostMapping("/add")
    public Result addBooking(@RequestBody ActivityBooking activityBooking) {
        return activityBookingService.addBooking(activityBooking);
    }

    @PutMapping("/update")
    public Result updateBooking(@RequestBody ActivityBooking activityBooking) {
        return activityBookingService.updateBooking(activityBooking);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteBooking(@PathVariable Integer id) {
        return activityBookingService.deleteBooking(id);
    }

    @PostMapping("/batch")
    public Result batchDeleteBookings(@RequestBody List<Integer> ids) {
        return activityBookingService.batchDeleteBookings(ids);
    }
}
